package shuai.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import shuai.biz.PhoneBiz;
import shuai.biz.PhoneBizImpl;
import shuai.biz.PhoneBizImplProxy;
import shuai.util.OutOfStockException;

public class Demo {
	@Test
	public void test1() throws OutOfStockException{
		PhoneBiz phoneBiz=new PhoneBizImplProxy();
		phoneBiz.buyPhone(100);
		phoneBiz.salePhone(50);
		System.out.println(phoneBiz.getClass().getName());
	}
	
	@Test
	public void test2() throws OutOfStockException{
		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
		PhoneBiz phoneBiz=ac.getBean("phoneBizImpl",PhoneBiz.class);
		phoneBiz.buyPhone(100);
		phoneBiz.salePhone(50);
		System.out.println(phoneBiz.getClass().getName());
	}
}
